<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>个人信息-修改昵称</title>
	<link rel="stylesheet" href="__PUBLIC__/Mobile/css/zhang.css">
	<script src="__PUBLIC__/Mobile/js/jquery-1.7.2.min.js"></script>
	<script src="__PUBLIC__/Mobile/Layer/layer.min.js"></script>
</head>

<body >
<section>
<!--修改昵称-->
<div class="lm">
	<a href="javascript:history.back(-1);">
		<img src="__PUBLIC__/Mobile/images/return.png" style="height:22px; padding-left:2%; line-height:22px; width:6%; padding-top:2%;" class="left">
	</a>
    <span class="left size20">修改姓名 </span>
</div>
<div class="Logon1">
	<p>
	  <input name="username" type="text"  class="size18" value="{$find.username}" id="username">
	  <input type="hidden" name="name" value="{$find.username}">
   </p>
</div>
<div class="size18 Shared gray">2-12个字符，可由中英文、数字、汉字组成</div>
<button class="immediately2 size26" style="border:none;" id="button">确定</button>
</section>
<script>
		/* function clearInput(){
	        document.getElementById("username").value="";
	    } */
		$("#button").click(function(){
			var username = $("input[name=username]").val();
			var nicheng = $("input[name=name]").val();
			if(!username){
				layer.msg('昵称不能为空',2);
    			return false;
			}
			if(username == nicheng){
				layer.msg('您未做任何更改',2);
    			return false;
			}
			if(!(/^[\u4e00-\u9fa50-9a-zA-Z_\-]{2,12}$/.test(username))){
				layer.msg('2-12个字符,可由中英文、数字、"_"、"-"组成,且不能全部为数字',2);
    			return false;
			}
			$.ajax({
	   			 url: "{:U('Mycenter/change_name')}",
	             type: "POST",
	             data: {username:username},
	             dataType: "json",
	             success: function(result){
	             	if(result.isok=='ok'){
	                 	layer.alert('修改成功',1);
	                 	location.href = "{:U('Mycenter/person_information')}";
	               	}else if(result.isok=='off'){
	                 	layer.msg('修改失败',2);
	               	}
	               	//return;
	            }
	        });
		});
	</script>
</body>
</html>
